/* 
 * File:   cfgparser.h
 * Author: najar
 *
 * Created on 9 Январь 2010 г., 13:53
 */


#ifndef _CFGPARSER_H
#define	_CFGPARSER_H

#include <boost/regex.hpp>
#include <string>
#include <map>
#include <list>

using namespace std;

class CfgParser
{
public:
    CfgParser(bool);
    ~CfgParser();

    vector<string> * getAgentIps() const
    {
        return m_agent_ips;
    }

    vector<string> * getAgentHosts() const
    {
        return m_agent_hosts;
    }

    const list<string> * getListOfAdmins() const
    {
        return m_admins;
    }

    const string * getBotIp() const
    {
        return &m_botIp;
    }

    const string * getBotJid() const
    {
        return &m_botJid;
    }

    const string * getBotPswd() const
    {
        return &m_botPswd;
    }

    map<string, bool> * getServices() const
    {
        return m_services;
    }

    const list<string> * getAlerts() const
    {
        return m_alerts;
    }

    const string * getServicePath() const
    {
        return &m_servicePath;
    }

    const uint * getFsThreshold() const
    {
        return &m_fsThreshold;
    }

    const float * getLaThreshold() const
    {
        return &m_laThreshold;
    }

    const ulong * getFreeMemThreshold() const
    {
        return &m_freeMemThreshold;
    }

protected:
    void openServerConfig();
    void openAgentConfig();

private:
    bool m_isServer;
    uint m_fsThreshold;
    float m_laThreshold;
    ulong  m_freeMemThreshold;
    string m_servicePath;
    boost::regex m_commentMatcher, m_agentsMatcher, m_admMatcher, m_botMatcher,
    m_ipMatcher, m_jidMatcher, m_servicesMatcher, m_alertsMatcher,
    m_fsThresholdMatcher, m_laThresholdMatcher, m_pathMatcher, m_memThresholdMatcher,
    m_spaceMatcher;
    vector<string> * m_agent_ips;
    vector<string> * m_agent_hosts;
    list<string> * m_admins, * m_alerts;
    map<string, bool> * m_services;
    string m_botIp, m_botJid, m_botPswd;
    bool isConfigValid();

};
#endif	/* _CFGPARSER_H */

